$(document).ready(function(){
	
	/*----------------------------------------
	Backend Delete News and Announcement
	----------------------------------------*/
	$('.delete').live('click', function() {
		var id = $(this).attr('id');
		if ($(this).hasClass("news")) {
			var category = "news";
			var category_cn = "新闻";
		} else if ($(this).hasClass("announcement")) {
			var category = "announcement";
			var category_cn = "公告";
		}
		ajax_delete_news_announcement(id, category, category_cn)
	});
	
	function ajax_delete_news_announcement(id, category, category_cn) {
		$(".confirm_dialog").remove();
		
		$("#content").append(
			"<div class='confirm_dialog' title='确认删除?'>" +
				"<form>" +
				"<p><span class='ui-icon ui-icon-alert' style='float:left; margin:9px 5px 5px 0;'></span>确定要删除该" + category_cn + "吗?<br />" + category_cn + "删除后将无法恢复</p>" +
				"</form>" +
			"</div>"
		);
		$(".confirm_dialog").dialog({
			resizable: false,
			draggable: false,
			modal: true,
			//width: 373,
			//height: 330,
			buttons: {
				"是": function() {
					$.get('/index.php/backend/society/' + category + '/delete/' + id,
						function(){
							window.location.reload();
						}
					);
				},
				"否": function() {
					$(this).dialog( "close" );
				}
			}
		});
	}
});